const { tool,time,api } = getApp();
Page({

    data: {
        topic: {},  // 课题信息
        topic_state:['待审核','已驳回','可预约','预约中','已被预约'],//课题状态
        role:0,   
    },

    // 立即报名
    enroll() {
        api.getStorage('userInfo').then(info => {
            let { open_id } = info;
            tool.sign({ open_id,topic_id: this.data.topic.id }).then(res => {
              api.showToast('报名成功','success');
          })
        })
    },
    agree(){
      tool.toExmaine({topic_id:this.data.topic.id,state:2}).then(res=>{
        api.showToast("操作成功",'success')
        setTimeout(()=>{api.navigateBack(1)},1000)
        
      })
    },
    reject(){
      tool.toExmaine({topic_id:this.data.topic.id,state:1}).then(res=>{
        api.showToast("操作成功",'success');
        setTimeout(()=>{api.navigateBack(1)},1000)
      })
    },

    // 页面加载
    onLoad(options) {
        let { id } = options;
        tool.getTopicDetails(id).then(topic => {
            this.setData({ topic });
        })
        api.getStorage('role').then(role=>{
          this.setData({role})
        })
    },
    
})